using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Roslyn.Compilers.CSharp;
using Roslyn.Compilers.Common;
using Roslyn.Services;

namespace ContentOverContainer
{
    public class ReferencesList : List<NodeTypeInfo>
    {
        /// <summary>
        /// Pushes all nodes of the given stack to the current stack.
        /// </summary>
        /// <param name="pNodesToAdd">The stack hodling the nodes to be pushed ont the other stack.</param>
        /// <param name="pNewType">New type of the p.</param>
        /// <author>
        /// Harald Binkle
        /// </author>
        public void Add(IEnumerable<SyntaxNode> pNodesToAdd, MultiplicityInfo pMultiInfo, IDocument pDoc)
        {
            foreach (var pair in pNodesToAdd)
            {
                this.Add(new NodeTypeInfo(pair, pMultiInfo, pDoc));
            }
        }

        /// <summary>
        /// Adds the specified p stack.
        /// </summary>
        /// <param name="pStack">The p stack.</param>
        /// <author>Harald Binkle</author>
        public void Add(ReferencesList pStack)
        {
            foreach (var reference in pStack)
            {
                this.Add(reference);
            }
        }

    }

    /// <summary>
    /// Class encapsulating info needed later on to process referenced nodes.
    /// </summary>
    /// <author>Harald Binkle</author>
    public class NodeTypeInfo
    {
        public SyntaxNode Node { get; set; }
        public MultiplicityInfo MultiplicityInfo { get; set; }
        public IDocument Document { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="NodeTypeInfo"/> class.
        /// </summary>
        /// <param name="pNode">The p node.</param>
        /// <param name="pType">Type of the p.</param>
        /// <param name="pDoc">The p doc.</param>
        /// <author>Harald Binkle</author>
        public NodeTypeInfo(SyntaxNode pNode, MultiplicityInfo pMultiInfo, IDocument pDoc)
        {
            Node = pNode;
            MultiplicityInfo = pMultiInfo;
            Document = pDoc;
        }

        public override string ToString()
        {
            return Node.ToString();
        }
    }
}
